/*
 * Copyright 2018-present Open Networking Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.onosproject.segmentrouting;

import com.google.common.base.MoreObjects;

import java.util.Objects;

import static com.google.common.base.MoreObjects.toStringHelper;

/**
 * Utility class used to temporarily store information about the ports on a
 * device processed for filtering objectives.
 */
public final class PortFilterInfo {
    int disabledPorts = 0, errorPorts = 0, filteredPorts = 0;

    public PortFilterInfo(int disabledPorts, int errorPorts,
                          int filteredPorts) {
        this.disabledPorts = disabledPorts;
        this.filteredPorts = filteredPorts;
        this.errorPorts = errorPorts;
    }

    @Override
    public int hashCode() {
        return Objects.hash(disabledPorts, filteredPorts, errorPorts);
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if ((obj == null) || (!(obj instanceof PortFilterInfo))) {
            return false;
        }
        PortFilterInfo other = (PortFilterInfo) obj;
        return ((disabledPorts == other.disabledPorts) &&
                (filteredPorts == other.filteredPorts) &&
                (errorPorts == other.errorPorts));
    }

    @Override
    public String toString() {
        MoreObjects.ToStringHelper helper = toStringHelper(this)
                .add("disabledPorts", disabledPorts)
                .add("errorPorts", errorPorts)
                .add("filteredPorts", filteredPorts);
        return helper.toString();
    }
}